<!-- 租机业务员信息 -->
<template>
  <div class="table">
    <SearchTable v-model:formStatus="formStatus" :rentStaffTypeList="rentStaffTypeList" ref="searchTableRef" @handleViewEdit="handleViewEdit" />
    <FormDialog v-model:formStatus="formStatus" v-model:form="form" :rentStaffTypeList="rentStaffTypeList" @handleSuccess="handleSuccess" />
  </div>
</template>

<script setup lang="ts" name="rentSalesmanInfo">
import SearchTable from "@/components/user/rentSalesmanInfo/SearchTable.vue";
import FormDialog from "@/components/user/rentSalesmanInfo/FormDialog.vue";
import type { ViewMode, ViewModeFilter } from "@/types/common";
import type { IRentStaff, IRentStaffVO } from "@/types/staff/rentStaff";
import { useDictData } from "@/hooks/network/useDictData";
import type { IDictData } from "@/types/dict";
let { getDictData } = useDictData();
/* 表格子组件的引用 */
const searchTableRef = useTemplateRef("searchTableRef");
const formStatus = ref<ViewMode>("none");
/* 业务员类型 */
const rentStaffTypeList = ref<Array<IDictData>>([]);
const form = reactive<IRentStaff>({
  id: 0,
  mobile: "",
  user_id: 0,
  username: "",
  type: ""
});
/* 点击编辑按钮 */
function handleViewEdit(row: IRentStaffVO, code: ViewModeFilter) {
  nextTick(() => {
    form.id = row.id;
    form.mobile = row.mobile;
    form.type = row.type;
    form.user_id = row.user_id;
    form.username = row.username;
    formStatus.value = code;
  });
}
/* 成功保存或者编辑的回调 */
function handleSuccess() {
  searchTableRef.value?.getTableInfo();
}
getDictData("RENT_STAFF_TYPE", rentStaffTypeList);
</script>

<style scoped></style>
